#pragma once
#include "NetConnect.h"
class CNetConnectManage
{
public:
	CNetConnectManage();
	~CNetConnectManage();
public:
	/// Add the specified connection to the manager and start it.
	void Start(PNetConnect c);

	/// Stop the specified connection.
	void Stop(PNetConnect c, int WaitSecond);

	void UpdateDevice(CNetConnect* c);
	/// Stop all connections.
	void Stop_All();

	static SharedPointer<CNetConnectManage> GetInstance()
	{
		if (!m_pNetConnectMange.get())
		{
			m_pNetConnectMange = SharedPointer<CNetConnectManage>(new CNetConnectManage());
		}
		return m_pNetConnectMange;
	}

	bool PushNewDataWrite(SharedPointer<ZMVector<unsigned char>>& buffer);
private:
	/// The managed connections.
	QMap<int, PNetConnect> m_connections;//deviceid , device
	list<PNetConnect> m_lsConncetNotInit;
	static SharedPointer<CNetConnectManage> m_pNetConnectMange;
};
typedef SharedPointer<CNetConnectManage> PNetConnectManage;
